package otcv.hr.webapp.dao;

import java.sql.SQLException;
import java.util.List;

import otcv.hr.log.Logger;
import otcv.hr.webapp.entity.MemberEntity;
import otcv.hr.webapp.entity.MemberSchEntity;

/**
 * @author : H-Thien
 * @comment : Member Data Access Object
 */
public class MemberDAO extends Dao {

	/**
	 * @comment : member list total count
	 */
	public String memberTotalCnt(MemberSchEntity sch) throws SQLException {
		String totCnt = "0";

		try {
			totCnt = (String) sqlMap.queryForObject("member.memberTotalCnt", sch);
		} catch (SQLException e) {
			Logger.error("[MemberDAO]memberTotalCnt, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {

		}

		return totCnt;
	}

	/**
	 * @comment : member list
	 */
	public List<MemberEntity> listMember(MemberSchEntity sch) throws SQLException {
		List<MemberEntity> list = null;
		try {
			list = sqlMap.queryForList("member.listMember", sch);
		} catch (SQLException e) {
			Logger.error("[MemberDAO]listMember, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {

		}

		return list;
	}

	/**
	 * @comment : member detail
	 */
	public MemberEntity detailMember(MemberEntity key) throws SQLException {
		MemberEntity member = null;

		try {
			member = (MemberEntity) sqlMap.queryForObject("member.detailMember", key);
		} catch (SQLException e) {
			Logger.error("[MemberDAO]updateMember, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {
			sqlMap.endTransaction();
		}

		return member;
	}

	/**
	 * @comment : entryCnt count
	 */
	public String entryCnt(MemberEntity sch) throws SQLException {
		String totCnt = "0";

		try {
			totCnt = (String) sqlMap.queryForObject("member.entryCnt", sch);
		} catch (SQLException e) {
			Logger.error("[MemberDAO]entryCnt, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {

		}

		return totCnt;
	}

	/**
	 * @comment : winCnt count
	 */
	public String winCnt(MemberEntity sch) throws SQLException {
		String totCnt = "0";

		try {
			totCnt = (String) sqlMap.queryForObject("member.winCnt", sch);
		} catch (SQLException e) {
			Logger.error("[MemberDAO]winCnt, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {

		}

		return totCnt;
	}

	/**
	 * @comment : winCnt count
	 */
	public String totalWinMoney(MemberEntity sch) throws SQLException {
		String totCnt = "0";

		try {
			totCnt = (String) sqlMap.queryForObject("member.totalWinMoney", sch);
		} catch (SQLException e) {
			Logger.error("[MemberDAO]totalWinMoney, SQLException:" + e);
			throw new SQLException(e.toString());
		} finally {

		}

		return totCnt;
	}

}